<script setup lang='ts'>
import { ref, useSlots } from 'vue';
import { PageContainerProps } from '../types';
import ProTabs from '../ProTabs/index.vue';
const slots = useSlots();

const props = withDefaults(defineProps<PageContainerProps>(), ({
    tabsAttrs: () => ({}),
}));
</script>

<template>
    <div class="page-container">
        <div v-if="!props.hideBread" class="page-container-bread">
            <t-breadcrumb>
                <t-breadcrumbItem v-for="bread in props.breads" :to="bread.path" :href="bread.href"
                    :target="bread.target" :disabled="bread.disabled" :replace="bread.replace">{{ bread.text
                    }}</t-breadcrumbItem>
            </t-breadcrumb>
        </div>
        <div v-if="!props.hideTitle || props.title" class="page-container-title">
            <div>
                <span v-if="!slots.title">{{ props.title }}</span>
                <slot v-else name="title"></slot>
            </div>
            <div>
                <slot name="actions"></slot>
            </div>
        </div>
        <div v-if="props.content || slots.content" class="page-container-content">
            <span v-if="!slots.content">{{ props.content }}</span>
            <slot v-else name="content"></slot>
        </div>
        <div v-if="props.tabs" class="page-container-tabs">
            <ProTabs :defaultValue="props.tabDefaultValue" :tabAttrs="props.tabsAttrs" :tabs="props.tabs">
                <template v-if="slots.tabContent" #default="{ key }">
                    <slot name="tabContent" :key="key"></slot>
                </template>
            </ProTabs>
        </div>
        <div class="page-container-footer">
            <slot name="footer"></slot>
        </div>
    </div>
</template>

<style lang='scss'>
.page-container {
    padding: 0px 8px;
}

.page-container-bread {
    margin-bottom: 8px;
}

.page-container-title {
    font-weight: bold;
    margin: 0px 12px 0px 0px;
    font-weight: 600;
    font-size: 20px;
    line-height: 32px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-container-content {
    padding-top: 12px;
}

.page-container-tabs {
    padding-top: 8px;
}

.page-container-footer {
    margin-top: 36px;
}
</style>